﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Diagnostics;

namespace DiagnosticAndMonitorinApp
{
    /// <summary>
    /// Lógica de interacción para MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();

            PerformanceCounter pc = new PerformanceCounter();

            if (!PerformanceCounterCategory.CounterExists("startUpTimes", "MyCounter"))
            PerformanceCounterCategory.Create("MyCounter", "for mya app counters", PerformanceCounterCategoryType.SingleInstance, "startUpTimes", "numbers of start up");
         
            pc = new System.Diagnostics.PerformanceCounter("MyCounter", "startUpTimes", false);
            
            pc.Increment();

           
            Trace.Write("#########3 PROBANDO TRACE!!!!!!!!!1");
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            throw new Exception("Excepción forzada!!!!");
        }

        private void Button_Click_1(object sender, RoutedEventArgs e)
        {

            if (!EventLog.SourceExists("DiagnosticAndMonitoringApp"))
            {
                EventLog.CreateEventSource("DiagnosticAndMonitoringApp", "MyLog");
            }

            // Create an EventLog instance and assign its source.
            EventLog myLog = new EventLog();
            
            myLog.Source = "DiagnosticAndMonitoringApp";

            // Write an informational entry to the event log.    
            myLog.WriteEntry("Usando Event Log!!!",EventLogEntryType.Information);
            

            foreach (EventLogEntry item in myLog.Entries)
            {
                Debug.Print(item.Message);

                
            }

        }
    }
}
